/**
 * 工程名称:OMS
 * 文件名称:SysRefundController.java
 * 所属包:cn.rkylin.oms.sysreturn.controller
 * 创建时间:2017年9月21日下午2:54:30
 * 创建人:zhanghao
 */

package cn.rkylin.oms.aftersale.sysreturn.controller;

import java.net.URLDecoder;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;

import cn.rkylin.core.controller.ApolloController;
import cn.rkylin.oms.aftersale.sysrefund.servcie.ISysRefundService;
import cn.rkylin.oms.aftersale.sysreturn.dao.ISysReturnDAO;
import cn.rkylin.oms.aftersale.sysreturn.service.ISysReturnService;
import cn.rkylin.oms.aftersale.sysreturn.vo.ReturnInfoVO;
import cn.rkylin.oms.aftersale.sysreturn.vo.SysReturnVO;
import cn.rkylin.oms.common.annotation.SystemControllerLog;
import cn.rkylin.oms.common.context.CurrentUser;
import cn.rkylin.oms.common.context.WebContextFactory;
import cn.rkylin.oms.common.export.IExport;
import cn.rkylin.oms.order.service.IOrderService;
import cn.rkylin.oms.order.vo.OrderSkuVO;

/**
 * 类名:SysRefundController <br/>
 * 作用: 系统退货单操作Controller. <br/>
 * 创建原因: 对外提供系统退款单相关操作. <br/>
 * 创建时间: 2017年9月21日 下午2:54:30 <br/>
 *
 * @author zhanghao
 * @see
 */
@Controller
@RequestMapping("/sysReturnManager")
public class SysReturnController extends ApolloController {
    private static final Log logger = LogFactory.getLog(SysReturnController.class);
    /**
     * sysRefundService:系统退货单服务层
     */
    @Autowired
    private ISysRefundService sysRefundService;
    @Autowired
    private IOrderService orderService;
    @Autowired
    private ISysReturnService sysReturnService;

    @Override
    public void afterPropertiesSet() throws Exception {
        setExportService((IExport) sysRefundService);
    }

    /**
     * 按条件查询退货单信息列表(分页)
     *
     * @param quickSearch
     *            快速查询字符串
     * @param start
     *            起始Index
     * @param length
     *            数据数
     * @param formJson
     *            高级查询表单数据
     * @param queryStatus
     *            列表状态
     * @return
     * @throws Exception
     * @author zhanghao
     */
    @ResponseBody
    @RequestMapping(value = "/sysReturnList")
    public Map<String, Object> getSysReturnList(String quickSearch, @RequestParam(required = false, defaultValue = "0") int start,
            @RequestParam(required = false, defaultValue = "10") int length, String formJson, String queryStatus) throws Exception {

        SysReturnVO queryParamVO = new SysReturnVO();
        // 快速查询
        if (StringUtils.isNotBlank(quickSearch)) {
            quickSearch = URLDecoder.decode(quickSearch, "UTF-8");
            if (StringUtils.isNotBlank(quickSearch)) {
                queryParamVO.setQuickSearch(quickSearch);
            }
        }
        // 高级查询
        if (StringUtils.isNotBlank(formJson)) {
            formJson = URLDecoder.decode(formJson, "UTF-8");
            Map<String, String> mapItem = JSONObject.parseObject(formJson, Map.class);
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
            if (mapItem != null && mapItem.size() > 0) {
                if (StringUtils.isNotBlank(mapItem.get("shopId"))) {
                    queryParamVO.setShopId(mapItem.get("shopId"));
                }
                if (StringUtils.isNotBlank(mapItem.get("storId"))) {
                    queryParamVO.setStorId(mapItem.get("storId"));
                }
                if (StringUtils.isNotBlank(mapItem.get("goodsCode"))) {
                    queryParamVO.setGoodsCode(mapItem.get("goodsCode"));
                }
                if (StringUtils.isNotBlank(mapItem.get("goodsName"))) {
                    queryParamVO.setGoodsName(mapItem.get("goodsName"));
                }
                if (StringUtils.isNotBlank(mapItem.get("skuCode"))) {
                    queryParamVO.setSkuCode(mapItem.get("skuCode"));
                }
                if (StringUtils.isNotBlank(mapItem.get("skuName"))) {
                    queryParamVO.setSkuName(mapItem.get("skuName"));
                }
                if (StringUtils.isNotBlank(mapItem.get("dateType"))) {
                    queryParamVO.setDateType(mapItem.get("dateType"));
                }
                if (StringUtils.isNotBlank(mapItem.get("startTimeInput"))) {
                    queryParamVO.setStartTimeInput(sdf.parse(mapItem.get("startTimeInput")));
                }
                if (StringUtils.isNotBlank(mapItem.get("endTimeInput"))) {
                    queryParamVO.setEndTimeInput(sdf.parse(mapItem.get("endTimeInput")));
                }
                if (StringUtils.isNotBlank(mapItem.get("factStockin"))) {
                    queryParamVO.setFactStockin(mapItem.get("factStockin"));
                }
                if (StringUtils.isNotBlank(mapItem.get("hasRerutnInfo"))) {
                    queryParamVO.setHasRerutnInfo(mapItem.get("hasRerutnInfo").toString());
                }

            }
        }

        Map<String, String> replaceFieldsMap = new HashMap<String, String>();
        // 排序语句生成
        String orderStatement = getOrderString(ISysReturnDAO.class.getName(), "selectSelectiveSysReturn", replaceFieldsMap);
        if (StringUtils.isNotBlank(orderStatement)) {
            queryParamVO.setOrderBy(orderStatement);
        }

        // 获取当前登录人
        CurrentUser currentUser = WebContextFactory.getWebContext().getCurrentUser();
        if (currentUser == null) {
            return getFailedMap("查询当前登录人失败");
        }

        // 获取当前登录人所属项目
        String projectId = currentUser.getCurrentProject().getPrjId();
        if (StringUtils.isBlank(projectId)) {
            return getFailedMap("查询当前登录人所属项目失败");
        } else {
            queryParamVO.setPrjId(projectId);
        }
        // 设置Tab页参数
        if (StringUtils.isNotBlank(queryStatus)) {
            queryParamVO.setQueryStatus(queryStatus);
        }

        // 处理分页信息
        if (length == -1) {
            length = Integer.MAX_VALUE;
        }
        int page = start / length + 1;

        // 执行查询
        PageInfo<SysReturnVO> ruleVOList = sysReturnService.getSysReturnListByCondition(page, length, queryParamVO);

        Map<String, Object> returnMap = null;
        if (null != ruleVOList) {
            returnMap = getSuccessMap("查询系统退货单数据成功");
            returnMap.put(RECORDS_FILTERED, ruleVOList.getTotal());
            returnMap.put(RECORDS_TOTAL, ruleVOList.getTotal());
            returnMap.put(RETURN_DATA, ruleVOList.getList());
        } else {
            returnMap = getFailedMap("查询系统退货单数据失败");
        }
        logger.info("查询系统退货单调用结束");
        return returnMap;
    }

    /**
     * 获取各个Tab页上的数量
     *
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/queryStateCount")
    public Map<String, Object> queryStateCount(String quickSearch, String formJson) throws Exception {
        Map returnMap = new HashMap();
        List<HashMap> stateMap = new ArrayList<HashMap>();

        SysReturnVO queryParamVO = new SysReturnVO();
        // 登录与权限检测
        CurrentUser currentUser = logonCheck(returnMap);
        queryParamVO.setPrjId(currentUser.getCurrentProject().getPrjId());
        // 快速查询
        if (StringUtils.isNotBlank(quickSearch)) {
            quickSearch = URLDecoder.decode(quickSearch, "UTF-8");
            if (StringUtils.isNotBlank(quickSearch)) {
                queryParamVO.setQuickSearch(quickSearch);
            }
        }
        // 高级查询
        if (StringUtils.isNotBlank(formJson)) {
            formJson = URLDecoder.decode(formJson, "UTF-8");
            Map<String, String> mapItem = JSONObject.parseObject(formJson, Map.class);
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
            if (mapItem != null && mapItem.size() > 0) {
                if (StringUtils.isNotBlank(mapItem.get("shopId"))) {
                    queryParamVO.setShopId(mapItem.get("shopId"));
                }
                if (StringUtils.isNotBlank(mapItem.get("storId"))) {
                    queryParamVO.setStorId(mapItem.get("storId"));
                }
                if (StringUtils.isNotBlank(mapItem.get("goodsCode"))) {
                    queryParamVO.setGoodsCode(mapItem.get("goodsCode"));
                }
                if (StringUtils.isNotBlank(mapItem.get("goodsName"))) {
                    queryParamVO.setGoodsName(mapItem.get("goodsName"));
                }
                if (StringUtils.isNotBlank(mapItem.get("skuCode"))) {
                    queryParamVO.setSkuCode(mapItem.get("skuCode"));
                }
                if (StringUtils.isNotBlank(mapItem.get("skuName"))) {
                    queryParamVO.setSkuName(mapItem.get("skuName"));
                }
                if (StringUtils.isNotBlank(mapItem.get("dateType"))) {
                    queryParamVO.setDateType(mapItem.get("dateType"));
                }
                if (StringUtils.isNotBlank(mapItem.get("startTimeInput"))) {
                    queryParamVO.setStartTimeInput(sdf.parse(mapItem.get("startTimeInput")));
                }
                if (StringUtils.isNotBlank(mapItem.get("endTimeInput"))) {
                    queryParamVO.setEndTimeInput(sdf.parse(mapItem.get("endTimeInput")));
                }
                if (StringUtils.isNotBlank(mapItem.get("factStockin"))) {
                    queryParamVO.setFactStockin(mapItem.get("factStockin"));
                }
                if (StringUtils.isNotBlank(mapItem.get("hasRerutnInfo"))) {
                    queryParamVO.setHasRerutnInfo(mapItem.get("hasRerutnInfo").toString());
                }

            }
        }

        try {
            stateMap = sysReturnService.findStateCount(queryParamVO);
        } catch (Exception e) {
            logger.error(e.getMessage());
            returnMap = getFailedMap("获取状态数据失败");
        }
        returnMap = getSuccessMap("完成根据ID查询规则数据");
        returnMap.put(RETURN_DATA, stateMap);
        return returnMap;
    }

    /**
     * 获取退货单的明细信息，包括基本信息，计划退入商品，实际退入商品
     *
     * @param sysReturnId
     * @return
     * @author wangxing
     */
    @ResponseBody
    @RequestMapping(value = "/sysReturnFullDetail")
    public Map<String, Object> sysReturnFullDetail(@RequestParam(value = "sysReturnId") String sysReturnId) {
        // logger.info(String.format("系统调用获取系统退款单明细：/sysRefundManager/sysReturnFullDetail/%s",
        // sysRefundId));
        // 用于返回值的json对象
        Map<String, Object> returnMap = null;
        try {
            SysReturnVO result = sysReturnService.selectByPrimaryKey(sysReturnId);
            if (null != result) {
                returnMap = getSuccessMap("系统调用完成");
                returnMap.put(RETURN_DATA, result);
            }
        } catch (Exception e) {
            logger.error(e.getMessage());
            returnMap = getFailedMap(e.getMessage());
        }
        return returnMap;
    }

    /**
     * sysRefundDetail:根据退货单ID获取系统退货单详情. <br/>
     *
     * @param sysReturnId
     * @return
     * @author wangxing
     */
    @ResponseBody
    @RequestMapping(value = "/sysReturnDetail", method = RequestMethod.GET)
    public Map<String, Object> sysReturnDetail(String sysReturnId) {
        // logger.info(String.format("系统调用获取系统退款单明细：/sysRefundManager/sysRefundDetail/%s",
        // sysReturnId));
        // 用于返回值的json对象
        Map<String, Object> returnMap = null;
        try {
            SysReturnVO result = sysReturnService.selectByPrimaryKeyOnly(sysReturnId);
            if (null != result) {
                returnMap = getSuccessMap("系统调用完成");
                returnMap.put(RETURN_DATA, result);
            }
        } catch (Exception e) {
            logger.error(e.getMessage());
            returnMap = getFailedMap(e.getMessage());
        }
        return returnMap;
    }

    /**
     * autoGenSysReturnBySysRefund:根据退款单ID生成退货单及其明细. <br/>
     *
     * @param refundIds
     * @return
     * @author zhanghao
     */
    @ResponseBody
    @RequestMapping(value = "/autoGenSysReturnBySysRefund")
    public Map<String, Object> autoGenSysReturnBySysRefund(@RequestParam(value = "refundIds") String refundIds) {
        logger.info(String.format("系统调用获取系统退款单商品明细：/sysReturnManager/autoGenSysReturnBySysRefund/%s", refundIds));
        // 用于返回值的json对象
        Map<String, Object> returnMap = null;
        String[] refundIdArray = refundIds.split(",");
        try {
            for (String sysRefundId : refundIdArray) {
                try {
                    sysReturnService.generateReturnSysByRefund(sysRefundId);
                } catch (Exception e) {
                    logger.error(e.getMessage());
                }
            }
            returnMap = getSuccessMap("退货单生成成功");
        } catch (Exception e) {
            logger.error(e.getMessage());
            returnMap = getFailedMap(e.getMessage());
        }
        return returnMap;
    }

    /**
     * 获取 订单和订单关联的补发单 商品信息
     *
     * @param orderId
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/getOrderSkuById")
    public Map<String, Object> getOrderSkuById(String orderId) {
        // logger.info(String.format("系统调用获取订单商品明细：/sysRefundManager/getOrderSkuById/%s",
        // orderId));
        // 用于返回值的json对象
        Map<String, Object> returnMap = null;
        try {
            List<OrderSkuVO> orderSkuList = orderService.getOrderSkuAndResendSkuByOrderId(orderId);
            if (orderSkuList != null && orderSkuList.size() > 0) {
                returnMap = getSuccessMap("系统调用完成");
                returnMap.put(RETURN_DATA, orderSkuList);
            } else {
                returnMap = getFailedMap("系统调用完成,未获取到数据");
            }

        } catch (Exception e) {
            logger.error(e.getMessage());
            returnMap = getFailedMap(e.getMessage());
        }
        return returnMap;
    }

    /**
     * 获取 退货单 商品信息
     *
     * @param returnId
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/getReturnSkuByReturnId")
    public Map<String, Object> getReturnSkuByReturnId(String returnId) {
        // logger.info(String.format("系统调用获取订单商品明细：/sysRefundManager/getOrderSkuById/%s",
        // orderId));
        // 用于返回值的json对象
        Map<String, Object> returnMap = null;
        try {
            List<OrderSkuVO> returnSkuList = sysReturnService.selectByReturnId(returnId, null);
            if (returnSkuList != null && returnSkuList.size() > 0) {
                returnMap = getSuccessMap("系统调用完成");
                returnMap.put(RETURN_DATA, returnSkuList);
            } else {
                returnMap = getFailedMap("系统调用完成,未获取到数据");
            }
        } catch (Exception e) {
            logger.error(e.getMessage());
            returnMap = getFailedMap(e.getMessage());
        }
        return returnMap;
    }

    /**
     * 保存系统退货单
     *
     * @param returnInfoVO
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/saveSysReturn", method = RequestMethod.POST)
    @SystemControllerLog(module = "系统退货单", operation = "保存系统退货单", keyCode = "returnId")
    public Map<String, Object> saveSysReturn(@RequestBody ReturnInfoVO returnInfoVO) {
        // logger.info(String.format("系统调用保存退款单及其明细：/sysRefundManager/saveSysRefund/%s",
        // orderSkuIds));
        // 用于返回值的json对象
        Map<String, Object> resultMap = null;
        try {
            CurrentUser currentUser = WebContextFactory.getWebContext().getCurrentUser();
            if (currentUser == null) {
                resultMap = getFailedMap("系统退货单保存失败，当前用户失效");
                logger.info("系统退货单保存失败，当前用户失效");
                return resultMap;
            }
            Map<String, String> mapParm = new HashMap<String, String>();
            Map<String, String> enterpriseMap = currentUser.getEnterpriseMap();
            if (enterpriseMap == null || enterpriseMap.size() == 0) {
                resultMap = getFailedMap("系统退货单保存失败，当前用户没有企业ID");
                logger.info("系统退货单保存失败，当前用户没有企业ID");
                return resultMap;
            }
            String entId = "";
            String entName = "";
            for (Map.Entry<String, String> entry : enterpriseMap.entrySet()) {
                entId = entry.getKey();
                entName = entry.getValue();
            }
            mapParm.put("entId", entId);
            mapParm.put("entName", entName);
            mapParm.put("prjId", currentUser.getCurrentProject().getPrjId());
            mapParm.put("prjName", currentUser.getCurrentProject().getPrjName());
            mapParm.put("prjShortName", currentUser.getCurrentProject().getPrjShortName());
            if (returnInfoVO != null) {
                returnInfoVO.setType("all");
            }

            Map<String, Object> map = sysReturnService.saveSysReturns(returnInfoVO, mapParm);
            if ("y".equals(map.get("isOk"))) {
                resultMap = getSuccessMap("系统退货单保存成功");
                logger.info("系统退货单保存成功");
            } else if ("s".equals(map.get("isOk"))) {
                resultMap = getSkuFailedMap(map.get("errorMessage").toString());
                logger.info("系统退货单保存失败，" + map.get("errorMessage").toString());
            } else {
                resultMap = getFailedMap(map.get("errorMessage").toString());
                logger.info("系统退货单保存失败，" + map.get("errorMessage").toString());
            }
        } catch (Exception e) {
            logger.error(e.getMessage());
            resultMap = getFailedMap(e.getMessage());
        }
        resultMap.put("returnId", returnInfoVO.getSysReturnVO().getReturnId());
        return resultMap;
    }

    /**
     * 手动删除系统退货单
     *
     * @param returnIds
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/deleteSysReturn")
    @SystemControllerLog(module = "系统退货单", operation = "手动删除系统退货单", keyCode = "returnId")
    public Map<String, Object> deleteSysReturn(String returnIds) {
        // logger.info(String.format("系统调用：/sysRefundManager/cancelSysRefund/%s",
        // returnIds));
        // String[] refundIdArray = StringUtils.split(refundIds, ",");
        // 用于返回值的json对象
        Map<String, Object> returnMap = null;
        try {
            int result = sysReturnService.deleteSysReturn(returnIds);
            if (result > 0) {
                returnMap = getSuccessMap("退货单删除成功");
            } else {
                returnMap = getFailedMap("退货单删除失败，请刷新后重试");
            }
        } catch (Exception e) {
            logger.error(e.getMessage());
            returnMap = getFailedMap(e.getMessage());
        }
        // 生成返回结果json串，null内容也需要返回
        returnMap.put("returnId", returnIds);
        return returnMap;
    }

    /**
     * 手动审核系统退货单校验：退货快递单号和退回物流公司不能为空
     *
     * @param returnIds
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/apprSysReturnCheck")
    public Map<String, Object> apprSysReturnCheck(String returnIds, String returnCodes) {
        // logger.info(String.format("系统调用审核退款单：/sysRefundManager/apprSysRefund/%s",
        // returnIds));
        String[] returnIdArray = StringUtils.split(returnIds, ",");
        JSONArray returnArray = new JSONArray();
        // 用于返回值的json对象
        Map<String, Object> returnMap = null;
        try {
            for (String sysReturnId : returnIdArray) {
                String result = sysReturnService.apprSysReturnCheck(sysReturnId);
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("returnId", sysReturnId);
                jsonObject.put("message", result);
                returnArray.add(jsonObject);
            }
            returnMap = getSuccessMap("审核退货单完成");
            returnMap.put("message", returnArray);
        } catch (Exception e) {
            logger.error(e.getMessage());
            returnMap = getFailedMap(e.getMessage());
        }
        // 生成返回结果json串，null内容也需要返回
        return returnMap;
    }

    /**
     * 手动审核系统退货单
     *
     * @param returnIds
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/apprSysReturn")
    @SystemControllerLog(module = "系统退货单", operation = "手动审核系统退货单", keyCode = "returnId")
    public Map<String, Object> apprSysReturn(String returnIds, String returnCodes) {
        // logger.info(String.format("系统调用审核退款单：/sysRefundManager/apprSysRefund/%s",
        // returnIds));
        String[] returnIdArray = StringUtils.split(returnIds, ",");
        JSONArray returnArray = new JSONArray();
        // 用于返回值的json对象
        Map<String, Object> returnMap = null;
        CurrentUser currentUser = WebContextFactory.getWebContext().getCurrentUser();
        String prjShortName = currentUser.getCurrentProject().getPrjShortName();
        try {
            for (String sysReturnId : returnIdArray) {
                String result = sysReturnService.apprSysReturn(sysReturnId, prjShortName, returnCodes);
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("returnId", sysReturnId);
                jsonObject.put("message", result);
                returnArray.add(jsonObject);
            }
            returnMap = getSuccessMap("审核退货单完成");
            returnMap.put("message", returnArray);
        } catch (Exception e) {
            logger.error(e.getMessage());
            returnMap = getFailedMap(e.getMessage());
        }
        // 生成返回结果json串，null内容也需要返回
        returnMap.put("returnId", returnIds);
        return returnMap;
    }

    /**
     * 手动取消系统退货单
     *
     * @param returnIds
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/cancelSysReturn")
    @SystemControllerLog(module = "系统退货单", operation = "手动取消系统退货单", keyCode = "returnId")
    public Map<String, Object> cancelSysReturn(String returnIds) {
        String[] returnIdArray = StringUtils.split(returnIds, ",");
        JSONArray returnArray = new JSONArray();
        // 用于返回值的json对象
        Map<String, Object> returnMap = null;
        try {
            for (String sysReturnId : returnIdArray) {
                String result = sysReturnService.cancelSysReturn(sysReturnId);
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("returnId", sysReturnId);
                jsonObject.put("message", result);
                returnArray.add(jsonObject);
            }
            returnMap = getSuccessMap("取消退货单完成");
            returnMap.put("message", returnArray);
        } catch (Exception e) {
            logger.error(e.getMessage());
            returnMap = getFailedMap(e.getMessage());
        }
        // 生成返回结果json串，null内容也需要返回
        returnMap.put("returnId", returnIds);
        return returnMap;
    }

    /**
     * getSuccessMap:获取成功消息Map. <br/>
     *
     * @param message
     * @return
     * @author zhanghao
     * @since JDK 1.6
     */
    private Map<String, Object> getSuccessMap(String message) {
        Map<String, Object> returnMap = new HashMap<String, Object>();
        returnMap.put(JSON_RESULT, SUCCESS);
        returnMap.put(JSON_MSG, message);
        return returnMap;
    }

    ;

    /**
     * getFailedMap:获取失败消息Map. <br/>
     *
     * @param message
     * @return
     * @author zhanghao
     * @since JDK 1.6
     */
    private Map<String, Object> getFailedMap(String message) {
        Map<String, Object> returnMap = new HashMap<String, Object>();
        returnMap.put(JSON_RESULT, FAILED);
        returnMap.put(JSON_MSG, message);
        return returnMap;
    }

    private Map<String, Object> getSkuFailedMap(String message) {
        Map<String, Object> returnMap = new HashMap<String, Object>();
        returnMap.put(JSON_RESULT, "skuError");
        returnMap.put(JSON_MSG, message);
        return returnMap;
    }

    @ResponseBody
    @RequestMapping(value = "/getSysReturnByOrderId")
    public Map<String, Object> getSysReturnByOrderId(@RequestParam(value = "orderId") String orderId) {
        // 用于返回值的json对象
        Map<String, Object> returnMap = null;
        try {
            List<SysReturnVO> sysReturnList = sysReturnService.findSysReturnByOrderId(orderId);
            if (sysReturnList.size() > 0) {
                returnMap = getSuccessMap("系统调用完成");
                returnMap.put(RETURN_DATA, sysReturnList);
            } else {
                returnMap = getFailedMap("系统调用完成,未获取到数据");
            }
        } catch (Exception e) {
            logger.error(e.getMessage());
            returnMap = getFailedMap(e.getMessage());
        }
        return returnMap;
    }

}
